//
//  ClockDKDRWTableViewCell.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/10/23.
//

#import "ClockDKDRWTableViewCell.h"

#import "YTBaseSelectStringView.h"
#import "YTBaseEditorStringView.h"
#import "DigitalInputView.h"
#import "TemplateFoundDetailsDXXZTableViewCell.h"
#import "TemplateFoundDetailsDHTableViewCell.h"
#import "YTSelectStringShowView.h"


@interface ClockDKDRWTableViewCell ()

@property (nonatomic ,strong) UIView * makeview;
@property (nonatomic ,strong) UIView * AllZview;

@end

@implementation ClockDKDRWTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setupView];
    }
    return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.whiteColor;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;
    
    UIView * makeview = [UIView new];
    self.makeview = makeview;
    makeview.clipsToBounds = YES;
    makeview.backgroundColor = UIColor.whiteColor;
    //    [DTKTool YJBK:kwt(5) andView:makeview andWidth:0.5 andColor:KcolorHex(@"#D9D9D9")];
    [self.contentView addSubview:makeview];
    [makeview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.offset(0);
        make.bottom.offset(kwt(-10));
    }];
    
    
}


- (void)setModel:(TemplateFoundDetailsTaskItemModelListModel *)model{
    _model = model;
    [self.makeview.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    
    MJWeakSelf
    /// 样式;1:多项选择 2:下单单选3:数字输入框4:单行文本 5:多行文本
    if(model.pattern == 1){
        UIView * dxview = [UIView new];
        dxview.backgroundColor = KcolorHex(@"#F6F7F9");
        [DTKTool YJ:kwt(5) andView:dxview];
        [self.makeview addSubview:dxview];
        [dxview mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(0);
            make.left.offset(kwt(10));
            make.right.offset(kwt(-10));
            make.height.offset(model.CellH - kwt(10));
        }];
        UILabel * leftLab = [DTKTool labelWithText:@"" andFont:kCFont(17) andTextColor:KcolorHex(@"#222222")];
        leftLab.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat: @"%@%@",((model.forceFlag == 1)?@"*":@""),model.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#FA0F0F") andFont:kCFont(17) andPattenr:@"[*]"];
        [dxview addSubview:leftLab];
        [leftLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(kwt(10));
            make.top.offset(kwt(16));
        }];
        UILabel * lab = [DTKTool labelWithText:@" (可多选)" andFont:kFont(17) andTextColor:KcolorHex(@"#7F7F7F")];
        [dxview addSubview:lab];
        lab.textAlignment = NSTextAlignmentCenter;
        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(leftLab.mas_right);
            make.centerY.equalTo(leftLab);
        }];
        CGFloat X = kwt(10);
        CGFloat Y = kwt(45);
        for (TemplateFoundDetailsItemModelListModel * childModel in model.itemModelList) {
            UIView * btnview = [UIView new];
            btnview.addClickBlock(^{
                [weakSelf btnclick:childModel];
            });
            [DTKTool YJBK:kwt(6) andView:btnview andWidth:1 andColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#BFBFBF")];
            UILabel * lab = [DTKTool labelWithText:childModel.name andFont:kFont(16) andTextColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#373C45")];
            [btnview addSubview:lab];
            lab.textAlignment = NSTextAlignmentCenter;
            [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.offset(kwt(10));
                make.right.offset(kwt(-10));
                make.centerY.offset(0);
            }];
            if(childModel.checkedFlag){
                UIImageView * xzimg = kimageView(@"template_selete");
                [btnview addSubview:xzimg];
                [xzimg mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.right.bottom.offset(0);
                    make.height.offset(kwt(11));
                    make.width.offset(kwt(10));
                }];
            }
            
            [dxview addSubview:btnview];
            if(X + childModel.nameW > kwt(340)){
                X = kwt(10);
                Y += kwt(48);
            }
            btnview.frame = CGRectMake(X, Y, childModel.nameW, kwt(32));
            X += childModel.nameW + kwt(14);
        }
        Y += kwt(45 + 10);
        
        ///绘制池塘
        for (pondModelListModel * pondmodel in model.pondModelList) {
            UIView * pondview = [UIView new];
            [DTKTool YJBK:kwt(5) andView:pondview andWidth:1 andColor:KcolorHex(@"#D9D9D9")];
            [self.makeview addSubview:pondview];
            [pondview mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.right.offset(0);
                make.top.offset(Y);
                make.height.offset([model modelWithPondModel:pondmodel].DKDRWDYTViewH - kwt(10));
            }];
            
            UILabel * nameLab = [DTKTool labelWithText:pondmodel.name andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
            [pondview addSubview:nameLab];
            [nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.offset(kwt(22));
                make.top.offset(kwt(17));
                make.height.offset(kwt(19));
            }];            
//            TemplateFoundDetailsTaskItemModelListModel * item = [model modelWithPondModel:pondmodel];
            
            UIImageView * sxBtn = kimageView([model modelWithPondModel:pondmodel].isDRWSQ?@"template_retract":@"template_expand");
//            NSLog(@"创建池塘:%@,任务名%@,是%@",pondmodel.name,item.name,item.isDRWSQ?@"打开":@"收缩");
//            UIImageView * sxBtn = kimageView([model modelWithPondModel:pondmodel].isDRWSQ?@"template_retract":@"template_expand");
            sxBtn.addClickBlock(^{
                [weakSelf pondViewClickWithModel:[model modelWithPondModel:pondmodel] andpondModel:pondmodel];
            });
            [pondview addSubview:sxBtn];
            [sxBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.equalTo(nameLab);
                make.width.height.offset(kwt(20));
                make.right.offset(kwt(-14));
            }];
            if([model modelWithPondModel:pondmodel].isDRWSQ){
                
            } else {
                ///提交子标题
                CGFloat itemY = kwt(45);
                ///筛选是否有选中子选项要绘制
                for (TemplateFoundDetailsItemModelListModel * childModel in [model modelWithPondModel:pondmodel].itemModelList) {///子选项绘制
                    if(childModel.checkedFlag == 1){
                        if(childModel.itemList.count > 1){///有副标题的
                            CGFloat fbtdxY = kwt(45);
                            
                            UIView * fbtdxview = [UIView new];
                            fbtdxview.backgroundColor = KcolorHex(@"#F6F7F9");
                            [DTKTool YJ:kwt(5) andView:fbtdxview];
                            [pondview addSubview:fbtdxview];
                            [fbtdxview mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.top.offset(itemY);
                                make.left.offset(kwt(10));
                                make.right.offset(kwt(-10));                      
                                make.height.offset(childModel.itemListViewH - kwt(10));
                            }];
                            UILabel * lab = [DTKTool labelWithText:childModel.name andFont:kFont(17) andTextColor:KcolorHex(@"#222222")];
                            [fbtdxview addSubview:lab];
                            [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.left.offset(kwt(10));
                                make.top.offset(kwt(14));
                                make.height.offset(kwt(18));
                            }];
                            for (TemplateFoundDetailsItemListModel * item in childModel.itemList) {
                                /// 样式;1:多项选择 2:下单单选3:数字输入框4:单行文本 5:多行文本
                                if(item.pattern == 1){
                                    CGFloat X = kwt(10);
                                    CGFloat dxY = kwt(45);
                                    UIView * dxview = [UIView new];
                                    dxview.backgroundColor = KcolorHex(@"#F6F7F9");
                                    [DTKTool YJ:kwt(5) andView:dxview];
                                    [fbtdxview addSubview:dxview];
                                    [dxview mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.top.offset(fbtdxY);
                                        make.left.right.offset(0);
                                        make.height.offset(item.viewH - kwt(10));
                                    }];
                                    
                                    UILabel * lab = [DTKTool labelWithText:@"" andFont:kCFont(17) andTextColor:KcolorHex(@"#222222")];
                                    lab.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat: @"%@%@",((item.forceFlag == 1)?@"*":@""),item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#FA0F0F") andFont:kCFont(17) andPattenr:@"[*]"];
                                    [dxview addSubview:lab];
                                    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.offset(kwt(10));
                                        make.top.offset(kwt(14));
                                        make.height.offset(kwt(18));
                                    }];
                                    UILabel * templab = [DTKTool labelWithText:@" (可多选)" andFont:kFont(17) andTextColor:KcolorHex(@"#7F7F7F")];
                                    [dxview addSubview:templab];
                                    templab.textAlignment = NSTextAlignmentCenter;
                                    [templab mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.equalTo(lab.mas_right);
                                        make.centerY.equalTo(lab);
                                    }];
                                    
//                                    forceFlag
//                                    UILabel * lab = [DTKTool labelWithText:@"-" andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
//                                    lab.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat:@"%@(可多选)",item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#7F7F7F") andFont:kCFont(18) andPattenr:@"(\\(可多选\\))"];
//                                    [dxview addSubview:lab];
//                                    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
//                                        make.left.offset(kwt(10));
//                                        make.top.offset(kwt(14));
//                                        make.height.offset(kwt(18));
//                                    }];
                                    
                                    for (TemplateFoundDetailsChildrenModelListModel * childModel in item.childrenModelList) {
                                        
                                        UIView * btnview = [UIView new];
                                        btnview.addClickBlock(^{
                                            [weakSelf btnclick:childModel];
                                        });
                                        [DTKTool YJBK:kwt(6) andView:btnview andWidth:1 andColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#BFBFBF")];
                                        UILabel * lab = [DTKTool labelWithText:childModel.name andFont:kFont(16) andTextColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#373C45")];
                                        [btnview addSubview:lab];
                                        lab.textAlignment = NSTextAlignmentCenter;
                                        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                                            make.left.offset(kwt(10));
                                            make.right.offset(kwt(-10));
                                            make.centerY.offset(0);
                                        }];
                                        if(childModel.checkedFlag){
                                            UIImageView * xzimg = kimageView(@"template_selete");
                                            [btnview addSubview:xzimg];
                                            [xzimg mas_makeConstraints:^(MASConstraintMaker *make) {
                                                make.right.bottom.offset(0);
                                                make.height.offset(kwt(11));
                                                make.width.offset(kwt(10));
                                            }];
                                        }
                                        
                                        [dxview addSubview:btnview];
                                        if(X + childModel.nameW > kwt(340)){
                                            X = kwt(10);
                                            dxY += kwt(48);
                                        }
                                        btnview.frame = CGRectMake(X, dxY, childModel.nameW, kwt(32));
                                        X += childModel.nameW + kwt(10);
                                    }
                                    
                                    fbtdxY+= item.viewH - kwt(10);
                                } else  if(item.pattern == 2){
                                    YTBaseSelectStringView * view = [YTBaseSelectStringView NewViewWithNil];
                                    view.forceFlag = item.forceFlag;
                                    view.name = item.name;
                                    view.content = item.seledModel.name;
                                    view.block = ^(NSString * _Nonnull content) {
                                        NSMutableArray * nameArray = [NSMutableArray array];
                                        int i = 0;
                                        int selectIndex = 0;
                                        for (TemplateFoundDetailsChildrenModelListModel * itemmodel in item.childrenModelList) {
                                            [nameArray addObject:itemmodel.name];
                                            if([item.seledModel.name isEqualToString: itemmodel.name]){
                                                selectIndex = i;
                                            }
                                            i ++;
                                        }
                                        [BRStringPickerView showPickerWithTitle:[NSString stringWithFormat:@"请选择%@",item.name] dataSourceArr:nameArray selectIndex:selectIndex resultBlock:^(BRResultModel * _Nullable resultModel) {
                                            for (TemplateFoundDetailsChildrenModelListModel * itemmodel in item.childrenModelList) {
                                                if([itemmodel.name isEqualToString:resultModel.value]){
                                                    itemmodel.checkedFlag = 1;
                                                } else {
                                                    itemmodel.checkedFlag = 0;
                                                }
                                            }
                                            if(weakSelf.openReloadBlock){
                                                weakSelf.openReloadBlock();
                                            }
                                        }];
                                    };
                                    [fbtdxview addSubview: view];
                                    [view mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.right.offset(0);
                                        make.top.offset(fbtdxY);
                                        make.height.offset(item.viewH);
                                    }];
                                    fbtdxY+=  item.viewH - kwt(10);
                                } else  if(item.pattern == 3){
                                    
                                    UIView * makeview = [UIView new];
                                    makeview.backgroundColor = KcolorHex(@"#F6F7F9");
                                    [DTKTool YJ:kwt(5) andView:makeview];
                                    [fbtdxview addSubview:makeview];
                                    [makeview mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.top.offset(fbtdxY);
                                        make.left.right.offset(0);
                                        make.height.offset(item.viewH - kwt(10));
                                    }];
                                    
                                    UILabel * name = [DTKTool labelWithText:@"" andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
                                    [makeview addSubview:name];
                                    name.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat:@"%@%@",(item.forceFlag==1)?@"*":@"",item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#FA0F0F") andFont:kCFont(18) andPattenr:@"[*]"];
                                    [name mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.offset(kwt(12));
                                        make.centerY.offset(0);
                                        make.width.offset(kwt(145));
                                    }];
                                    
                                    DigitalInputView * inputview = [DigitalInputView DKNewView];
                                    inputview.model = item;///有数据不管类型
                                    [makeview addSubview:inputview];
                                    inputview.openReloadBlock = ^{
                                        if(weakSelf.openReloadBlock){
                                            weakSelf.openReloadBlock();
                                        }
                                    };
                                    inputview.openHUDBlock = ^(NSString * _Nonnull str) {
                                        if(weakSelf.openHUDBlock){
                                            weakSelf.openHUDBlock(str);
                                        }
                                    };
                                    [inputview mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.right.offset(kwt(-12));
                                        make.centerY.offset(0);
                                        make.width.offset(kwt(170));
                                        make.height.offset(kwt(32));
                                    }];
                                    
                                    
                                    fbtdxY+=  item.viewH - kwt(10);
                                    
                                } else  if(item.pattern == 4){
                                    
                                    YTBaseEditorStringView * view = [YTBaseEditorStringView NewViewWithNil];
                                    view.forceFlag = item.forceFlag;
                                    view.name = item.name;
                                    view.content = item.content;
                                    view.block = ^(NSString * _Nonnull content) {
                                        item.content = content;
                                    };
                                    
                                    [fbtdxview addSubview: view];
                                    [view mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.right.offset(0);
                                        make.top.offset(fbtdxY);
                                        make.height.offset(item.viewH);
                                    }];
                                    fbtdxY+= item.viewH;
                                } else  if(item.pattern == 5){
                                    TemplateFoundDetailsDHView * view = [TemplateFoundDetailsDHView NewView];
                                    view.model = item;
                                    [fbtdxview addSubview: view];
                                    [view mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.right.offset(0);
                                        make.top.offset(fbtdxY);
                                        make.height.offset(item.viewH);
                                    }];
                                    fbtdxY+=  item.viewH - kwt(10);
                                }
                            }
                            itemY += childModel.itemListViewH;
                        } else {
                            for (TemplateFoundDetailsItemListModel * item in childModel.itemList) {
                                /// 样式;1:多项选择 2:下单单选3:数字输入框4:单行文本 5:多行文本
                                if(item.pattern == 1){
                                    CGFloat X = kwt(10);
                                    CGFloat dxY = kwt(45);
                                    UIView * dxview = [UIView new];
                                    dxview.backgroundColor = KcolorHex(@"#F6F7F9");
                                    [DTKTool YJ:kwt(5) andView:dxview];
                                    [pondview addSubview:dxview];
                                    [dxview mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.top.offset(itemY);
                                        make.left.offset(kwt(10));
                                        make.right.offset(kwt(-10));
                                        make.height.offset(item.viewH - kwt(10));
                                    }];
                                    
                                    
                                    UILabel * lab = [DTKTool labelWithText:@"" andFont:kCFont(17) andTextColor:KcolorHex(@"#222222")];
                                    lab.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat: @"%@%@",((item.forceFlag == 1)?@"*":@""),item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#FA0F0F") andFont:kCFont(17) andPattenr:@"[*]"];
                                    [dxview addSubview:lab];
                                    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.offset(kwt(10));
                                        make.top.offset(kwt(14));
                                        make.height.offset(kwt(18));
                                    }];
                                    UILabel * templab = [DTKTool labelWithText:@"(可多选)" andFont:kFont(17) andTextColor:KcolorHex(@"#7F7F7F")];
                                    [dxview addSubview:templab];
                                    templab.textAlignment = NSTextAlignmentCenter;
                                    [templab mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.equalTo(lab.mas_right);
                                        make.centerY.equalTo(lab);
                                    }];
                                    
//                                    UILabel * lab = [DTKTool labelWithText:@"-" andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
//                                    lab.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat:@"%@ (可多选)",item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#7F7F7F") andFont:kCFont(18) andPattenr:@"(\\(可多选\\))"];
//                                    [dxview addSubview:lab];
//                                    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
//                                        make.left.offset(kwt(10));
//                                        make.top.offset(kwt(14));
//                                        make.height.offset(kwt(18));
//                                    }];
                                    
                                    for (TemplateFoundDetailsChildrenModelListModel * childModel in item.childrenModelList) {
                                        
                                        UIView * btnview = [UIView new];
                                        btnview.addClickBlock(^{
                                            [weakSelf ZRWbtnclick:childModel];
                                        });
                                        [DTKTool YJBK:kwt(6) andView:btnview andWidth:1 andColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#BFBFBF")];
                                        UILabel * lab = [DTKTool labelWithText:childModel.name andFont:kFont(16) andTextColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#373C45")];
                                        [btnview addSubview:lab];
                                        lab.textAlignment = NSTextAlignmentCenter;
                                        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                                            make.left.offset(kwt(10));
                                            make.right.offset(kwt(-10));
                                            make.centerY.offset(0);
                                        }];
                                        if(childModel.checkedFlag){
                                            UIImageView * xzimg = kimageView(@"template_selete");
                                            [btnview addSubview:xzimg];
                                            [xzimg mas_makeConstraints:^(MASConstraintMaker *make) {
                                                make.right.bottom.offset(0);
                                                make.height.offset(kwt(11));
                                                make.width.offset(kwt(10));
                                            }];
                                        }
                                        
                                        [dxview addSubview:btnview];
                                        if(X + childModel.nameW > kwt(340)){
                                            X = kwt(10);
                                            dxY += kwt(48);
                                        }
                                        btnview.frame = CGRectMake(X, dxY, childModel.nameW, kwt(32));
                                        X += childModel.nameW + kwt(10);
                                    }
                                    itemY+= item.viewH;
                                } else  if(item.pattern == 2){
                                    YTBaseSelectStringView * view = [YTBaseSelectStringView NewViewWithUP];
                                    view.forceFlag = item.forceFlag;
                                    view.name = item.name;
                                    view.content = item.seledModel.name;
                                    view.block = ^(NSString * _Nonnull content) {
                                        NSMutableArray * nameArray = [NSMutableArray array];
                                        int i = 0;
                                        int selectIndex = 0;
                                        for (TemplateFoundDetailsChildrenModelListModel * itemmodel in item.childrenModelList) {
                                            [nameArray addObject:itemmodel.name];
                                            if([item.seledModel.name isEqualToString: itemmodel.name]){
                                                selectIndex = i;
                                            }
                                            i ++;
                                        }
                                        [BRStringPickerView showPickerWithTitle:[NSString stringWithFormat:@"请选择%@",item.name] dataSourceArr:nameArray selectIndex:selectIndex resultBlock:^(BRResultModel * _Nullable resultModel) {
                                            for (TemplateFoundDetailsChildrenModelListModel * itemmodel in item.childrenModelList) {
                                                if([itemmodel.name isEqualToString:resultModel.value]){
                                                    itemmodel.checkedFlag = 1;
                                                } else {
                                                    itemmodel.checkedFlag = 0;
                                                }
                                            }
                                            if(weakSelf.openReloadBlock){
                                                weakSelf.openReloadBlock();
                                            }
                                        }];
                                    };
                                    [pondview addSubview: view];
                                    [view mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.offset(kwt(10));
                                        make.right.offset(kwt(-10));                                        make.top.offset(itemY);
                                        make.height.offset(item.viewH);
                                    }];
                                    itemY+= item.viewH;
                                } else  if(item.pattern == 3){
                                    
                                    UIView * makeview = [UIView new];
                                    makeview.backgroundColor = KcolorHex(@"#F6F7F9");
                                    [DTKTool YJ:kwt(5) andView:makeview];
                                    [pondview addSubview:makeview];
                                    [makeview mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.top.offset(itemY);
                                        make.left.offset(kwt(10));
                                        make.right.offset(kwt(-10));                                        make.height.offset(item.viewH - kwt(10));
                                    }];
                                    
                                    UILabel * name = [DTKTool labelWithText:@"" andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
                                    [makeview addSubview:name];
                                    name.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat:@"%@%@",(item.forceFlag==1)?@"*":@"",item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#FA0F0F") andFont:kCFont(18) andPattenr:@"[*]"];
                                    [name mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.offset(kwt(12));
                                        make.centerY.offset(0);
                                        make.width.offset(kwt(145));
                                    }];
                                    
                                    DigitalInputView * inputview = [DigitalInputView DKNewView];
                                    inputview.model = item;///有数据不管类型
                                    [makeview addSubview:inputview];
                                    inputview.openReloadBlock = ^{
                                        if(weakSelf.openReloadBlock){
                                            weakSelf.openReloadBlock();
                                        }
                                    };
                                    inputview.openHUDBlock = ^(NSString * _Nonnull str) {
                                        if(weakSelf.openHUDBlock){
                                            weakSelf.openHUDBlock(str);
                                        }
                                    };
                                    [inputview mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.right.offset(kwt(-12));
                                        make.centerY.offset(0);
                                        make.width.offset(kwt(170));
                                        make.height.offset(kwt(32));
                                    }];
                                    
                                    
                                    itemY+= item.viewH;
                                    
                                } else  if(item.pattern == 4){
                                    
                                    YTBaseEditorStringView * view = [YTBaseEditorStringView NewViewWithUP];
                                    view.forceFlag = item.forceFlag;
                                    view.name = item.name;
                                    view.content = item.content;
                                    view.block = ^(NSString * _Nonnull content) {
                                        item.content = content;
                                    };
                                    
                                    [pondview addSubview: view];
                                    [view mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.offset(kwt(10));
                                        make.right.offset(kwt(-10));                                        make.top.offset(itemY);
                                        make.height.offset(item.viewH);
                                    }];
                                    itemY+= item.viewH;
                                } else  if(item.pattern == 5){
                                    TemplateFoundDetailsDHView * view = [TemplateFoundDetailsDHView NewView];
                                    view.model = item;
                                    [pondview addSubview: view];
                                    [view mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.offset(kwt(10));
                                        make.right.offset(kwt(-10));                                        make.top.offset(itemY);
                                        make.height.offset(item.viewH);
                                    }];
                                    itemY+= item.viewH;
                                }
                            }
                        }
                    }
                }
            }
            
            
            
            ///---
            Y += [model modelWithPondModel:pondmodel].DKDRWDYTViewH;
        }
    }
    else if(model.pattern == 2){///下单选
        YTBaseSelectStringView * dxview = [YTBaseSelectStringView NewViewWithNil];
        dxview.name = model.name;
        dxview.forceFlag = model.forceFlag;
        dxview.content = model.itemSeledModel.name;
        dxview.makeColor = KcolorHex(@"#F6F7F9");
        dxview.block = ^(NSString * _Nonnull content) {
            NSMutableArray * array = [NSMutableArray array];
            for (TemplateFoundDetailsItemModelListModel * itemModel in model.itemModelList) {
                [array addObject:itemModel.name];
            }
            [YTSelectStringShowView showViewWithTitle:[NSString stringWithFormat:@"选择%@",model.name] andIndex:0 andDateArray:array andBlock:^(NSString * _Nonnull str) {
                for (TemplateFoundDetailsItemModelListModel * itemModel in model.itemModelList) {
                    if([itemModel.name isEqualToString:str]){
                        itemModel.checkedFlag = 1;
                    } else{
                        itemModel.checkedFlag = 0;
                    }
                }
                for (pondModelListModel * pond in model.pondModelList) {
                    for (TemplateFoundDetailsTaskItemModelListModel * listmodel in pond.taskItemModelList) {
                        for (TemplateFoundDetailsItemModelListModel * listitemmodel in listmodel.itemModelList) {
                                if([listitemmodel.name isEqualToString:str]){
                                    listitemmodel.checkedFlag = 1;
                                } else{
                                    listitemmodel.checkedFlag = 0;
                                }
                            
                        }
                    }
                }
                if(weakSelf.openReloadBlock){
                    weakSelf.openReloadBlock();
                }
            }];
        };
        [self.makeview addSubview:dxview];
        [dxview mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(kwt(10));
            make.right.offset(kwt(-10));
            make.top.offset(0);
            make.height.offset(kwt(53));
        }];
        
        CGFloat X = kwt(10);
        CGFloat Y = kwt(63);
        
        ///绘制池塘
        for (pondModelListModel * pondmodel in model.pondModelList) {
            UIView * pondview = [UIView new];
            [DTKTool YJBK:kwt(5) andView:pondview andWidth:1 andColor:KcolorHex(@"#D9D9D9")];
            [self.makeview addSubview:pondview];
            [pondview mas_makeConstraints:^(MASConstraintMaker *make) {
            
                make.left.right.offset(0);
                make.top.offset(Y);
                make.height.offset([model modelWithPondModel:pondmodel].DKDRWDYTViewH - kwt(10));
            }];
            
            UILabel * nameLab = [DTKTool labelWithText:pondmodel.name andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
            [pondview addSubview:nameLab];
            [nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.offset(kwt(22));
                make.top.offset(kwt(17));
                make.height.offset(kwt(19));
            }];
            TemplateFoundDetailsTaskItemModelListModel * item = [model modelWithPondModel:pondmodel];
            
            UIImageView * sxBtn = kimageView(item.isDRWSQ?@"template_retract":@"template_expand");
//            NSLog(@"创建池塘:%@,任务名%@,是%@",pondmodel.name,item.name,item.isDRWSQ?@"打开":@"收缩");
//            UIImageView * sxBtn = kimageView([model modelWithPondModel:pondmodel].isDRWSQ?@"template_retract":@"template_expand");
            sxBtn.addClickBlock(^{
                [weakSelf pondViewClickWithModel:[model modelWithPondModel:pondmodel] andpondModel:pondmodel];
            });
            [pondview addSubview:sxBtn];
            [sxBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.equalTo(nameLab);
                make.width.height.offset(kwt(20));
                make.right.offset(kwt(-14));
            }];
            if([model modelWithPondModel:pondmodel].isDRWSQ){
                
            } else {
                ///提交子标题
                CGFloat itemY = kwt(45);
                ///筛选是否有选中子选项要绘制
                for (TemplateFoundDetailsItemModelListModel * childModel in [model modelWithPondModel:pondmodel].itemModelList) {///子选项绘制
                    if(childModel.checkedFlag == 1){
                        if(childModel.itemList.count > 1){///有副标题的
                            CGFloat fbtdxY = kwt(45);
                            
                            UIView * fbtdxview = [UIView new];
                            fbtdxview.backgroundColor = KcolorHex(@"#F6F7F9");
                            [DTKTool YJ:kwt(5) andView:fbtdxview];
                            [pondview addSubview:fbtdxview];
                            [fbtdxview mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.top.offset(itemY);
                                make.left.offset(kwt(10));
                                make.right.offset(kwt(-10));
                                make.height.offset(childModel.itemListViewH - kwt(10));
                            }];
                            UILabel * lab = [DTKTool labelWithText:childModel.name andFont:kFont(17) andTextColor:KcolorHex(@"#222222")];
                            [fbtdxview addSubview:lab];
                            [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.left.offset(kwt(10));
                                make.top.offset(kwt(14));
                                make.height.offset(kwt(18));
                            }];
                            for (TemplateFoundDetailsItemListModel * item in childModel.itemList) {
                                /// 样式;1:多项选择 2:下单单选3:数字输入框4:单行文本 5:多行文本
                                if(item.pattern == 1){
                                    CGFloat X = kwt(10);
                                    CGFloat dxY = kwt(45);
                                    UIView * dxview = [UIView new];
                                    dxview.backgroundColor = KcolorHex(@"#F6F7F9");
                                    [DTKTool YJ:kwt(5) andView:dxview];
                                    [fbtdxview addSubview:dxview];
                                    [dxview mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.top.offset(fbtdxY);
                                        make.left.right.offset(0);
                                        make.height.offset(item.viewH - kwt(10));
                                    }];
                                    
                                    UILabel * lab = [DTKTool labelWithText:@"" andFont:kCFont(17) andTextColor:KcolorHex(@"#222222")];
                                    lab.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat: @"%@%@",((item.forceFlag == 1)?@"*":@""),item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#FA0F0F") andFont:kCFont(17) andPattenr:@"[*]"];
                                    [dxview addSubview:lab];
                                    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.offset(kwt(10));
                                        make.top.offset(kwt(14));
                                        make.height.offset(kwt(18));
                                    }];
                                    UILabel * templab = [DTKTool labelWithText:@" (可多选)" andFont:kFont(17) andTextColor:KcolorHex(@"#7F7F7F")];
                                    [dxview addSubview:templab];
                                    templab.textAlignment = NSTextAlignmentCenter;
                                    [templab mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.equalTo(lab.mas_right);
                                        make.centerY.equalTo(lab);
                                    }];
                                    
//                                    forceFlag
//                                    UILabel * lab = [DTKTool labelWithText:@"-" andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
//                                    lab.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat:@"%@(可多选)",item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#7F7F7F") andFont:kCFont(18) andPattenr:@"(\\(可多选\\))"];
//                                    [dxview addSubview:lab];
//                                    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
//                                        make.left.offset(kwt(10));
//                                        make.top.offset(kwt(14));
//                                        make.height.offset(kwt(18));
//                                    }];
                                    
                                    for (TemplateFoundDetailsChildrenModelListModel * childModel in item.childrenModelList) {
                                        
                                        UIView * btnview = [UIView new];
                                        btnview.addClickBlock(^{
                                            [weakSelf btnclick:childModel];
                                        });
                                        [DTKTool YJBK:kwt(6) andView:btnview andWidth:1 andColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#BFBFBF")];
                                        UILabel * lab = [DTKTool labelWithText:childModel.name andFont:kFont(16) andTextColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#373C45")];
                                        [btnview addSubview:lab];
                                        lab.textAlignment = NSTextAlignmentCenter;
                                        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                                            make.left.offset(kwt(10));
                                            make.right.offset(kwt(-10));
                                            make.centerY.offset(0);
                                        }];
                                        if(childModel.checkedFlag){
                                            UIImageView * xzimg = kimageView(@"template_selete");
                                            [btnview addSubview:xzimg];
                                            [xzimg mas_makeConstraints:^(MASConstraintMaker *make) {
                                                make.right.bottom.offset(0);
                                                make.height.offset(kwt(11));
                                                make.width.offset(kwt(10));
                                            }];
                                        }
                                        
                                        [dxview addSubview:btnview];
                                        if(X + childModel.nameW > kwt(340)){
                                            X = kwt(10);
                                            dxY += kwt(48);
                                        }
                                        btnview.frame = CGRectMake(X, dxY, childModel.nameW, kwt(32));
                                        X += childModel.nameW + kwt(10);
                                    }
                                    
                                    fbtdxY+= item.viewH - kwt(10);
                                } else  if(item.pattern == 2){
                                    YTBaseSelectStringView * view = [YTBaseSelectStringView NewViewWithNil];
                                    view.forceFlag = item.forceFlag;
                                    view.name = item.name;
                                    view.content = item.seledModel.name;
                                    view.block = ^(NSString * _Nonnull content) {
                                        NSMutableArray * nameArray = [NSMutableArray array];
                                        int i = 0;
                                        int selectIndex = 0;
                                        for (TemplateFoundDetailsChildrenModelListModel * itemmodel in item.childrenModelList) {
                                            [nameArray addObject:itemmodel.name];
                                            if([item.seledModel.name isEqualToString: itemmodel.name]){
                                                selectIndex = i;
                                            }
                                            i ++;
                                        }
                                        [BRStringPickerView showPickerWithTitle:[NSString stringWithFormat:@"请选择%@",item.name] dataSourceArr:nameArray selectIndex:selectIndex resultBlock:^(BRResultModel * _Nullable resultModel) {
                                            for (TemplateFoundDetailsChildrenModelListModel * itemmodel in item.childrenModelList) {
                                                if([itemmodel.name isEqualToString:resultModel.value]){
                                                    itemmodel.checkedFlag = 1;
                                                } else {
                                                    itemmodel.checkedFlag = 0;
                                                }
                                            }
                                            if(weakSelf.openReloadBlock){
                                                weakSelf.openReloadBlock();
                                            }
                                        }];
                                    };
                                    [fbtdxview addSubview: view];
                                    [view mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.right.offset(0);
                                        make.top.offset(fbtdxY);
                                        make.height.offset(item.viewH);
                                    }];
                                    fbtdxY+=  item.viewH - kwt(10);
                                } else  if(item.pattern == 3){
                                    
                                    UIView * makeview = [UIView new];
                                    makeview.backgroundColor = KcolorHex(@"#F6F7F9");
                                    [DTKTool YJ:kwt(5) andView:makeview];
                                    [fbtdxview addSubview:makeview];
                                    [makeview mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.top.offset(fbtdxY);
                                        make.left.right.offset(0);
                                        make.height.offset(item.viewH - kwt(10));
                                    }];
                                    
                                    UILabel * name = [DTKTool labelWithText:@"" andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
                                    [makeview addSubview:name];
                                    name.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat:@"%@%@",(item.forceFlag==1)?@"*":@"",item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#FA0F0F") andFont:kCFont(18) andPattenr:@"[*]"];
                                    [name mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.offset(kwt(12));
                                        make.centerY.offset(0);
                                        make.width.offset(kwt(145));
                                    }];
                                    
                                    DigitalInputView * inputview = [DigitalInputView DKNewView];
                                    inputview.model = item;///有数据不管类型
                                    [makeview addSubview:inputview];
                                    inputview.openReloadBlock = ^{
                                        if(weakSelf.openReloadBlock){
                                            weakSelf.openReloadBlock();
                                        }
                                    };
                                    inputview.openHUDBlock = ^(NSString * _Nonnull str) {
                                        if(weakSelf.openHUDBlock){
                                            weakSelf.openHUDBlock(str);
                                        }
                                    };
                                    [inputview mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.right.offset(kwt(-12));
                                        make.centerY.offset(0);
                                        make.width.offset(kwt(170));
                                        make.height.offset(kwt(32));
                                    }];
                                    
                                    
                                    fbtdxY+=  item.viewH - kwt(10);
                                    
                                } else  if(item.pattern == 4){
                                    
                                    YTBaseEditorStringView * view = [YTBaseEditorStringView NewViewWithNil];
                                    view.forceFlag = item.forceFlag;
                                    view.name = item.name;
                                    view.content = item.content;
                                    view.block = ^(NSString * _Nonnull content) {
                                        item.content = content;
                                    };
                                    
                                    [fbtdxview addSubview: view];
                                    [view mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.right.offset(0);
                                        make.top.offset(fbtdxY);
                                        make.height.offset(item.viewH);
                                    }];
                                    fbtdxY+= item.viewH;
                                } else  if(item.pattern == 5){
                                    TemplateFoundDetailsDHView * view = [TemplateFoundDetailsDHView NewView];
                                    view.model = item;
                                    [fbtdxview addSubview: view];
                                    [view mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.right.offset(0);
                                        make.top.offset(fbtdxY);
                                        make.height.offset(item.viewH);
                                    }];
                                    fbtdxY+=  item.viewH - kwt(10);
                                }
                            }
                            itemY += childModel.itemListViewH;
                        } else {
                            for (TemplateFoundDetailsItemListModel * item in childModel.itemList) {
                                /// 样式;1:多项选择 2:下单单选3:数字输入框4:单行文本 5:多行文本
                                if(item.pattern == 1){
                                    CGFloat X = kwt(10);
                                    CGFloat dxY = kwt(45);
                                    UIView * dxview = [UIView new];
                                    dxview.backgroundColor = KcolorHex(@"#F6F7F9");
                                    [DTKTool YJ:kwt(5) andView:dxview];
                                    [pondview addSubview:dxview];
                                    [dxview mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.top.offset(itemY);
                                        make.left.offset(kwt(10));
                                        make.right.offset(kwt(-10));                                        make.height.offset(item.viewH - kwt(10));
                                    }];
                                    
                                    
                                    UILabel * lab = [DTKTool labelWithText:@"" andFont:kCFont(17) andTextColor:KcolorHex(@"#222222")];
                                    lab.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat: @"%@%@",((item.forceFlag == 1)?@"*":@""),item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#FA0F0F") andFont:kCFont(17) andPattenr:@"[*]"];
                                    [dxview addSubview:lab];
                                    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.offset(kwt(10));
                                        make.top.offset(kwt(14));
                                        make.height.offset(kwt(18));
                                    }];
                                    UILabel * templab = [DTKTool labelWithText:@" (可多选)" andFont:kFont(17) andTextColor:KcolorHex(@"#7F7F7F")];
                                    [dxview addSubview:templab];
                                    templab.textAlignment = NSTextAlignmentCenter;
                                    [templab mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.equalTo(lab.mas_right);
                                        make.centerY.equalTo(lab);
                                    }];
                                    
//                                    UILabel * lab = [DTKTool labelWithText:@"-" andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
//                                    lab.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat:@"%@(可多选)",item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#7F7F7F") andFont:kCFont(18) andPattenr:@"(\\(可多选\\))"];
//                                    [dxview addSubview:lab];
//                                    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
//                                        make.left.offset(kwt(10));
//                                        make.top.offset(kwt(14));
//                                        make.height.offset(kwt(18));
//                                    }];
                                    
                                    for (TemplateFoundDetailsChildrenModelListModel * childModel in item.childrenModelList) {
                                        
                                        UIView * btnview = [UIView new];
                                        btnview.addClickBlock(^{
                                            [weakSelf ZRWbtnclick:childModel];
                                        });
                                        [DTKTool YJBK:kwt(6) andView:btnview andWidth:1 andColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#BFBFBF")];
                                        UILabel * lab = [DTKTool labelWithText:childModel.name andFont:kFont(16) andTextColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#373C45")];
                                        [btnview addSubview:lab];
                                        lab.textAlignment = NSTextAlignmentCenter;
                                        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                                            make.left.offset(kwt(10));
                                            make.right.offset(kwt(-10));
                                            make.centerY.offset(0);
                                        }];
                                        if(childModel.checkedFlag){
                                            UIImageView * xzimg = kimageView(@"template_selete");
                                            [btnview addSubview:xzimg];
                                            [xzimg mas_makeConstraints:^(MASConstraintMaker *make) {
                                                make.right.bottom.offset(0);
                                                make.height.offset(kwt(11));
                                                make.width.offset(kwt(10));
                                            }];
                                        }
                                        
                                        [dxview addSubview:btnview];
                                        if(X + childModel.nameW > kwt(340)){
                                            X = kwt(10);
                                            dxY += kwt(48);
                                        }
                                        btnview.frame = CGRectMake(X, dxY, childModel.nameW, kwt(32));
                                        X += childModel.nameW + kwt(10);
                                    }
                                    itemY+= item.viewH;
                                } else  if(item.pattern == 2){
                                    YTBaseSelectStringView * view = [YTBaseSelectStringView NewViewWithUP];
                                    view.forceFlag = item.forceFlag;
                                    view.name = item.name;
                                    view.content = item.seledModel.name;
                                    view.block = ^(NSString * _Nonnull content) {
                                        NSMutableArray * nameArray = [NSMutableArray array];
                                        int i = 0;
                                        int selectIndex = 0;
                                        for (TemplateFoundDetailsChildrenModelListModel * itemmodel in item.childrenModelList) {
                                            [nameArray addObject:itemmodel.name];
                                            if([item.seledModel.name isEqualToString: itemmodel.name]){
                                                selectIndex = i;
                                            }
                                            i ++;
                                        }
                                        [BRStringPickerView showPickerWithTitle:[NSString stringWithFormat:@"请选择%@",item.name] dataSourceArr:nameArray selectIndex:selectIndex resultBlock:^(BRResultModel * _Nullable resultModel) {
                                            for (TemplateFoundDetailsChildrenModelListModel * itemmodel in item.childrenModelList) {
                                                if([itemmodel.name isEqualToString:resultModel.value]){
                                                    itemmodel.checkedFlag = 1;
                                                } else {
                                                    itemmodel.checkedFlag = 0;
                                                }
                                            }
                                            if(weakSelf.openReloadBlock){
                                                weakSelf.openReloadBlock();
                                            }
                                        }];
                                    };
                                    [pondview addSubview: view];
                                    [view mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.offset(kwt(10));
                                        make.right.offset(kwt(-10));                                        make.top.offset(itemY);
                                        make.height.offset(item.viewH);
                                    }];
                                    itemY+= item.viewH;
                                } else  if(item.pattern == 3){
                                    
                                    UIView * makeview = [UIView new];
                                    makeview.backgroundColor = KcolorHex(@"#F6F7F9");
                                    [DTKTool YJ:kwt(5) andView:makeview];
                                    [pondview addSubview:makeview];
                                    [makeview mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.top.offset(itemY);
                                        make.left.offset(kwt(10));
                                        make.right.offset(kwt(-10));                                        make.height.offset(item.viewH - kwt(10));
                                    }];
                                    
                                    UILabel * name = [DTKTool labelWithText:@"" andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
                                    [makeview addSubview:name];
                                    name.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat:@"%@%@",(item.forceFlag==1)?@"*":@"",item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#FA0F0F") andFont:kCFont(18) andPattenr:@"[*]"];
                                    [name mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.offset(kwt(12));
                                        make.centerY.offset(0);
                                        make.width.offset(kwt(145));
                                    }];
                                    
                                    DigitalInputView * inputview = [DigitalInputView DKNewView];
                                    inputview.model = item;///有数据不管类型
                                    [makeview addSubview:inputview];
                                    inputview.openReloadBlock = ^{
                                        if(weakSelf.openReloadBlock){
                                            weakSelf.openReloadBlock();
                                        }
                                    };
                                    inputview.openHUDBlock = ^(NSString * _Nonnull str) {
                                        if(weakSelf.openHUDBlock){
                                            weakSelf.openHUDBlock(str);
                                        }
                                    };
                                    [inputview mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.right.offset(kwt(-12));
                                        make.centerY.offset(0);
                                        make.width.offset(kwt(170));
                                        make.height.offset(kwt(32));
                                    }];
                                    
                                    
                                    itemY+= item.viewH;
                                    
                                } else  if(item.pattern == 4){
                                    
                                    YTBaseEditorStringView * view = [YTBaseEditorStringView NewViewWithUP];
                                    view.forceFlag = item.forceFlag;
                                    view.name = item.name;
                                    view.content = item.content;
                                    view.block = ^(NSString * _Nonnull content) {
                                        item.content = content;
                                    };
                                    
                                    [pondview addSubview: view];
                                    [view mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.offset(kwt(10));
                                        make.right.offset(kwt(-10));                                        make.top.offset(itemY);
                                        make.height.offset(item.viewH);
                                    }];
                                    itemY+= item.viewH;
                                } else  if(item.pattern == 5){
                                    TemplateFoundDetailsDHView * view = [TemplateFoundDetailsDHView NewView];
                                    view.model = item;
                                    [pondview addSubview: view];
                                    [view mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.left.offset(kwt(10));
                                        make.right.offset(kwt(-10));                                        make.top.offset(itemY);
                                        make.height.offset(item.viewH);
                                    }];
                                    itemY+= item.viewH;
                                }
                            }
                        }
                    }
                }
            }
            
            
            
            ///---
            Y += [model modelWithPondModel:pondmodel].DKDRWDYTViewH;
        }
        
    }
    else if(model.pattern == 3){
        UIView * view = [UIView new];
        [self.makeview addSubview:view];
        view.backgroundColor = KcolorHex(@"#F6F7F9");
        [view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(kwt(10));
            make.right.offset(kwt(-10));
            make.top.bottom.offset(0);

        }];
        UILabel * leftLab = [DTKTool labelWithText:@"" andFont:kCFont(17) andTextColor:KcolorHex(@"#222222")];
        leftLab.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat: @"%@%@",((model.forceFlag == 1)?@"*":@""),model.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#FA0F0F") andFont:kCFont(17) andPattenr:@"[*]"];
        [view addSubview:leftLab];
        [leftLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(kwt(10));
            make.centerY.offset(0);
        }];
        
        DigitalInputView * Inputview = [DigitalInputView NewView];
        [view addSubview:Inputview];
        Inputview.model = model;
        Inputview.openHUDBlock = weakSelf.openHUDBlock;
        Inputview.openReloadBlock = ^{
            if(weakSelf.openReloadBlock){
                weakSelf.openReloadBlock();
            }
        };
        [Inputview mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.offset(kwt(-10));
            make.centerY.offset(0);
            make.width.offset(kwt(125));
            make.height.offset(kwt(25));
        }];
        
        
    }
    else if(model.pattern == 4){
        YTBaseEditorStringView * view = [YTBaseEditorStringView NewViewWithNil];
        view.name = model.name;
        view.forceFlag = model.forceFlag;
        view.content = model.content;
        view.makeColor = KcolorHex(@"#F6F7F9");
        view.block = ^(NSString * _Nonnull content) {
            model.content = content;
            if(weakSelf.openReloadBlock){
                weakSelf.openReloadBlock();
            }
        };
        [self.makeview addSubview:view];
        [view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(kwt(10));
            make.right.offset(kwt(-10));
            make.top.bottom.offset(0);

        }];
    }
    else if( model.pattern == 5){
        TemplateFoundDetailsDHView * view = [TemplateFoundDetailsDHView NewView];
        view.model = model;
        [self.makeview addSubview: view];
        [view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(kwt(10));
            make.right.bottom.offset(kwt(-10));
            make.top.offset(0);

        }];
        
        
        
//        view.content = model.content;
//        view.makeColor = UIColor.whiteColor;
//        view.block = ^(NSString * _Nonnull content) {
//            model.content = content;
//            if(weakSelf.openReloadBlock){
//                weakSelf.openReloadBlock();
//            }
//        };
//        [self.makeview addSubview:view];
//        [view mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.right.offset(0);
//            make.top.offset(0);
//            make.height.offset(kwt(45));
//        }];
    }
}
///鱼塘收缩
- (void)pondViewClickWithModel:(TemplateFoundDetailsTaskItemModelListModel *)model andpondModel:(pondModelListModel *)pondModel{
    model.isDRWSQ = !model.isDRWSQ;
    for (pondModelListModel * pond in self.model.pondModelList) {///遍历池塘
        if([pondModel.ID isEqualToString:pond.ID]){///相同池塘
            for (TemplateFoundDetailsTaskItemModelListModel * listmodel in pond.taskItemModelList) {///池塘里的任务项
                if([listmodel.templateTaskitemId isEqualToString:model.templateTaskitemId]){
                    NSLog(@"池塘:%@,任务名%@,ID:%@,选中model的ID%@",pond.name,listmodel.name,listmodel.templateTaskitemId,model.templateTaskitemId);
                    listmodel.isDRWSQ = model.isDRWSQ;
                }
            }
        }
       
    }
    if(self.openReloadBlock){
        self.openReloadBlock();
    }
}
- (void)btnclick:(TemplateFoundDetailsItemModelListModel *)model {
    model.checkedFlag = (model.checkedFlag == 1)?0:1;
    for (pondModelListModel * pond in self.model.pondModelList) {
        for (TemplateFoundDetailsTaskItemModelListModel * listmodel in pond.taskItemModelList) {
            for (TemplateFoundDetailsItemModelListModel * listitemmodel in listmodel.itemModelList) {
                if([listitemmodel.templateItemId isEqualToString:model.templateItemId]){
                    listitemmodel.checkedFlag = model.checkedFlag;
                }
            }
        }
    }
    if(self.openReloadBlock){
        self.openReloadBlock();
    }
}

- (void)ZRWbtnclick:(TemplateFoundDetailsItemModelListModel *)model {
    model.checkedFlag = (model.checkedFlag == 1)?0:1;
//    for (pondModelListModel * pond in self.model.pondModelList) {
//        for (TemplateFoundDetailsTaskItemModelListModel * listmodel in pond.taskItemModelList) {
//            for (TemplateFoundDetailsItemModelListModel * listitemmodel in listmodel.itemModelList) {
//                if([listitemmodel.templateItemId isEqualToString:model.templateItemId]){
//                    listitemmodel.checkedFlag = model.checkedFlag;
//                }
//            }
//        }
//    }
    if(self.openReloadBlock){
        self.openReloadBlock();
    }
}
@end
